<ui:composition template="/WEB-INF/templates/template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

	<ui:define name="conteudo">
		<h:form id="form">
			<p:panel id="panel" header="Solicitação de Exame">
				<h:inputHidden value="#{exameBean.exame.id}" />
				<h:panelGrid columns="3">
					<p:outputLabel value="Nome Paciente: " for="paciente" />
					<p:inputText id="paciente" value="#{exameBean.pacienteId}"
						required="true" />
					<p:message for="paciente" />
					
					<p:outputLabel value="CRM medico Solicitante" for="medcli" />
					<p:inputText id="medcli" value="#{exameBean.medCliId}"
						required="true" />
					<p:message for="medcli" />
					
					<p:outputLabel value="Medico Responsavel pelo Exame" for="medLab" />
					<p:inputText id="medLab" value="#{exameBean.medLabId}"
						required="true" />
					<p:message for="medLab" />

					<p:outputLabel value="Nome da Instituição: " for="instituicao" />
					<p:inputText id="instituicao"
						value="#{exameBean.laboratorioId}" />
					<p:message for="instituicao" />
	
				</h:panelGrid>
				<p:commandButton value="Cadastrar"
					actionListener="#{exameBean.add}" update="form, :listaexame" />
			</p:panel>
		</h:form>
		<h:form id="listaexame">
			<p:panel header="Lista de Exames" >
				<p:dataTable id="exames" var="exame"
					value="#{exameBean.exames}" paginator="true" rows="5">

					<p:column headerText="Nome Paciente" style="width:24%">
						<h:outputText value="#{exame.paciente.nome}" />
					</p:column>

					<p:column headerText="Medico Solicitante" style="width:24%">
						<h:outputText value="#{exame.medicoClinica.nome}" />
					</p:column>
					
					<p:column headerText="Medico Responsavel" style="width:24%">
						<h:outputText value="#{exame.medicoLaboratorio.nome}" />
					</p:column>

					<p:column headerText="Instituição" style="width:24%">
						<h:outputText value="#{exame.laboratorio.nome}" />
					</p:column>

					<p:column style="width:24%">
						<p:commandButton update=":form" value="Editar"
							actionListener="#{exameBean.preparaAlteracao}">
							<f:param name="id" value="#{exame.id}" />
						</p:commandButton>
					</p:column>
					<p:column style="width:24%">
						<p:commandButton update=":listaexame" value="Remover"
							actionListener="#{exameBean.remove}">
							<f:param name="id" value="#{exame.id}" />
						</p:commandButton>
					</p:column>
				</p:dataTable>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>